home *** CD-ROM | disk | FTP | other *** search
/ Space & Astronomy / Space and Astronomy (October 1993).iso / pc / viewers / mac / jpeg2gif / djpeg_folder / readme
Text File  |  1991-11-06  |  19KB  |  392 lines

  1. The Independent JPEG Group's JPEG software
  2. ==========================================
  3.  
  4. README for release of  7-Oct-91
  5. ===============================
  6.  
  7. This distribution contains the first public release of the Independent JPEG
  8. Group's free JPEG software.  You are welcome to redistribute this software and
  9. to use it for any purpose, subject to the conditions under LEGAL ISSUES, below.
  10.  
  11. This software is still undergoing revision.  Updated versions may be obtained
  12. by anonymous FTP to uunet.uu.net; look under directory /graphics/jpeg.  This
  13. particular version will be archived as jpegsrc.v1.tar.Z.  If you don't have
  14. access to Internet FTP, UUNET's archives are also available via UUCP; contact
  15. postmaster@uunet.uu.net for information on retrieving files that way.
  16.  
  17. Please report any problems with this software to jpeg-info@uunet.uu.net.
  18.  
  19. If you intend to become a serious user of this software, please contact
  20. jpeg-info@uunet to be added to our electronic mailing list.  Then you'll be
  21. notified of updates and have a chance to participate in discussions, etc.
  22.  
  23. This software is the work of Tom Lane, Philip Gladstone, Luis Ortiz, and other
  24. members of the independent JPEG group.
  25.  
  26.  
  27. DISCLAIMER
  28. ==========
  29.  
  30. THIS SOFTWARE IS NOT COMPLETE NOR FULLY DEBUGGED.  It is not guaranteed to be
  31. useful for anything, nor to be compatible with subsequent releases, nor to be
  32. an accurate implementation of the JPEG standard.  (See LEGAL ISSUES for even
  33. more disclaimers.)
  34.  
  35.  
  36. WHAT'S HERE
  37. ===========
  38.  
  39. This distribution contains software to implement JPEG image compression and
  40. decompression.  JPEG is a standardized compression method for full-color and
  41. gray-scale images.  JPEG is intended for "real-world" scenes; cartoons and
  42. other non-realistic images are not its strong suit.  JPEG is lossy, meaning
  43. that the output image is not necessarily identical to the input image.  Hence
  44. you should not use JPEG if you have to have identical output bits.  However,
  45. on typical images of real-world scenes, very good compression levels can be
  46. obtained with hardly any visible change, and amazingly high compression levels
  47. can be obtained if you can tolerate a low-quality image.  For more details,
  48. see the references, or just experiment with various compression settings.
  49.  
  50. The software implements JPEG baseline and extended-sequential compression
  51. processes.  Provision is made for supporting all variants of these processes,
  52. although some uncommon parameter settings aren't implemented yet.  For legal
  53. reasons, we are not distributing code for the arithmetic-coding process; see
  54. LEGAL ISSUES.  At present we have made no provision for supporting the
  55. progressive or lossless processes defined in the standard.
  56.  
  57. The present software is still largely in the prototype stage.  It does not
  58. support all possible variants of the JPEG standard, and some functions have
  59. rather slow and/or crude implementations.  However, it is useful already.
  60.  
  61. The emphasis in designing this software has been on achieving portability and
  62. flexibility, while also making it fast enough to be useful.  We have not yet
  63. undertaken serious performance measurement or tuning; we intend to do so in
  64. the future.
  65.  
  66.  
  67. This software can be used on several levels:
  68.  
  69. * As canned software for JPEG compression and decompression.  Just edit the
  70.   Makefile and configuration files as needed (see SETUP), compile and go.
  71.   Members of the independent JPEG group will improve the out-of-the-box
  72.   functionality as time goes on.
  73.  
  74. * As the basis for other JPEG programs.  For example, you could incorporate
  75.   the decompressor into a general image viewing package by replacing the
  76.   output module with write-to-screen functions.  For an implementation on
  77.   specific hardware, you might want to replace some of the inner loops with
  78.   assembly code.  For a non-command-line-driven system, you might want a
  79.   different user interface.  (Members of the group will be producing Macintosh
  80.   and Amiga versions with appropriate user interfaces, for example.)
  81.  
  82. * As a toolkit for experimentation with JPEG and JPEG-like algorithms.  Most
  83.   of the individual decisions you might want to mess with are packaged up into
  84.   separate modules.  For example, the details of color-space conversion and
  85.   subsampling techniques are each localized in one compressor and one
  86.   decompressor module.  You'd probably also want to extend the user interface
  87.   to give you more detailed control over the JPEG compression parameters.
  88.  
  89. In particular, we welcome the use of this software as the basis for commercial
  90. products; no royalty is required.
  91.  
  92.  
  93. SETUP
  94. =====
  95.  
  96. The installation process is not very automatic; you will need at least some
  97. familiarity with C programming and program build procedures for your system.
  98. (Volunteers to work on improving this situation are welcome.  Also, we will
  99. probably start distributing pre-built binaries for popular systems at some
  100. point.)
  101.  
  102. First, select a makefile and copy it to "Makefile".  "makefile.unix"
  103. is appropriate for most Unix and Unix-like systems.  Special makefiles are
  104. included for various PC compilers.  If you don't see a makefile for your
  105. system, we recommend starting from makefile.unix.
  106.  
  107. Look over the Makefile and adjust options as needed.  In particular, you'll
  108. need to change the CC= and CFLAGS= definitions if you don't have gcc
  109. (makefile.unix only).  If you have a function-prototype-less compiler, be sure
  110. to uncomment the .c.o rule and say "make ansi2knr".  This will cause the
  111. source files to be preprocessed to change our ANSI-style function definitions
  112. to old-style definitions.  (Thanks to Peter Deutsch of Aladdin Enterprises for
  113. ansi2knr.)
  114.  
  115. Also look over jconfig.h and adjust #defines as necessary.  If you have an
  116. ANSI-compliant C compiler (gcc for instance), no changes should be necessary
  117. except perhaps for RIGHT_SHIFT_IS_UNSIGNED and TWO_FILE_COMMANDLINE.  For
  118. older compilers other mods may be needed, depending on what ANSI features are
  119. supported.  If you prefer, you can usually leave jconfig.h unmodified and add
  120. -D switches to the Makefile's CFLAGS= definition.
  121.  
  122. Then say "make".
  123.  
  124. If you have trouble with missing system include files or inclusion of the
  125. wrong ones, you can fix it in jinclude.h.  In particular, if you are using
  126. gcc on a machine with non-ANSI system include files, you are likely to find
  127. that jinclude.h tries to include the wrong files (because gcc defines
  128. __STDC__).  There's no good automatic solution to this, so you'll just have
  129. to hand-edit jinclude.h.
  130.  
  131. As a quick test of functionality we've included three sample files:
  132.     testorig.jpg    same as blkint.jpg from JPEG validation floppy.
  133.     testimg.ppm    output of djpeg testorig.jpg
  134.     testimg.jpg    output of cjpeg testimg.ppm
  135. The two .jpg files aren't identical due to different parameter choices (and
  136. wouldn't be anyway, since JPEG is lossy).  However, if you can generate
  137. duplicates of testimg.ppm and testimg.jpg then you probably have a working
  138. port.  "make test" will perform the necessary comparisons (by generating
  139. testout.ppm and testout.jpg and comparing these to testimg.*).  NOTE: this
  140. is far from an exhaustive test of the JPEG software; some modules, such as
  141. color quantization and GIF I/O, are not exercised at all.  It's just a quick
  142. test to give you some confidence that you haven't missed something major.
  143.  
  144. If you need to make a smaller version of the JPEG software, some optional
  145. functions can be removed at compile time.  See the xxx_SUPPORTED #defines
  146. in jconfig.h.  (Not a lot is actually removed right now, but as more optional
  147. stuff gets added, this mechanism will start to make a difference.)
  148.  
  149. If you want to incorporate the JPEG code as subroutines in a larger program,
  150. we recommend that you make libjpeg.a.  Then use the .h files and libjpeg.a as
  151. your interface to the JPEG functions.  Your surrounding program will have to
  152. provide functionality similar to what's in jcmain.c or jdmain.c, and you may
  153. want to replace jerror.c and possibly other modules depending on your needs.
  154. See the "architecture" file for more info.  If it seems to you that the system
  155. structure doesn't accommodate what you want to do, please contact the authors.
  156.  
  157. Special notes for Macintosh Think C users: If you have version 5.0 you should
  158. be able to just turn on __STDC__ through the compiler switch that enables
  159. that.  With version 4.0 you must manually edit jconfig.h to define PROTO,
  160. HAVE_UNSIGNED_CHAR, HAVE_UNSIGNED_SHORT, and const.  (It seems to be safe to
  161. just define __STDC__ to take care of the first three.)  When setting up
  162. project files, use the COBJECTS and DOBJECTS lists in makefile.unix as a guide
  163. to which files need to be included, and add the ANSI and Unix C libraries in a
  164. separate segment.  You may need to divide the JPEG files into more than one
  165. segment; you can do this pretty much as you please.
  166.  
  167.  
  168. USAGE
  169. =====
  170.  
  171. The user interface is pretty minimal at this point.  We haven't bothered to
  172. generate manual-page files since the switches badly need redesign.  At the
  173. moment, things work like this:
  174.  
  175. There are two programs, cjpeg to compress an image file into JPEG format,
  176. and djpeg to decompress.
  177.  
  178. On Unix systems, you say:
  179.     cjpeg [switches] [imagefile] >jpegfile
  180.     djpeg [switches] [jpegfile]  >imagefile
  181. The programs read the specified input file, or standard input if none is
  182. named.  They always write to standard output (with trace/error messages to
  183. standard error).  These conventions are handy for piping images between
  184. programs.
  185.  
  186. On PC, Macintosh, and Amiga systems, you say:
  187.     cjpeg [switches] imagefile jpegfile
  188.     djpeg [switches] jpegfile  imagefile
  189. i.e., both input and output files are named on the command line.  This style
  190. is a little more foolproof, and it loses no functionality if you don't have
  191. pipes.  You can get this style on Unix too, if you prefer, by defining
  192. TWO_FILE_COMMANDLINE in jconfig.h or in the Makefile.  You MUST use this style
  193. on any system that doesn't cope well with binary data fed through
  194. stdin/stdout.
  195.  
  196. Currently supported image file formats include raw-format PPM, raw-format PGM
  197. (for monochrome images), and GIF.  cjpeg recognizes the input image format
  198. automatically, but you have to tell djpeg which format to generate.
  199.  
  200. The only JPEG file format currently supported is a raw JPEG data stream.
  201. Unless modified, the programs use the JFIF conventions for variables left
  202. unspecified by the JPEG standard.  (In particular, cjpeg generates a JFIF APP0
  203. marker.)  Support for the JPEG-in-TIFF format will probably be added at some
  204. future date.
  205.  
  206. The command line switches for cjpeg are:
  207.  
  208.     -I        Generate noninterleaved JPEG file (not yet supported).
  209.  
  210.     -Q quality    Scale quantization tables to adjust quality.
  211.             Quality is 0 (worst) to 100 (best); default is 75.
  212.             (See below for more info.)
  213.  
  214.     -a        Use arithmetic coding rather than Huffman coding.
  215.             (Not currently supported, see LEGAL ISSUES.)
  216.  
  217.     -o        Perform optimization of entropy encoding parameters.
  218.             Without this, default Huffman or arithmetic
  219.             parameters are used.  -o makes the JPEG file a tad
  220.             smaller, but compression uses much more memory.
  221.             Image quality is unaffected by -o.
  222.  
  223.     -d        Enable debug printout.  More -d's give more printout.
  224.  
  225. Typically you'd use -Q settings of 50 or 75 or so.  -Q 100 will generate a
  226. quantization table of all 1's, meaning no quantization loss; then any
  227. differences between input and output images are due to subsampling or to
  228. roundoff error in the DCT or colorspace-conversion steps.  -Q values below 50
  229. may be useful for making real small, low-quality images.  Try -Q 2 (or so) for
  230. some amusing Cubist effects.  (Note that -Q values below about 25 generate
  231. 2-byte quantization tables, which are not decodable by pure baseline JPEG
  232. decoders.  cjpeg emits a warning message when you give such a -Q value.)
  233.  
  234. The command line switches for djpeg are:
  235.  
  236.     -G        Select GIF output format (implies -q, with default
  237.             of 256 colors).
  238.  
  239.     -b        Perform cross-block smoothing.  This is quite
  240.             memory-intensive and only seems to improve the image
  241.             at very low quality settings (-Q 10 to 20 or so).
  242.  
  243.     -g        Force gray-scale output even if input is color.
  244.  
  245.     -q N        Quantize to N colors.
  246.  
  247.     -D        Use Floyd-Steinberg dithering in color quantization.
  248.  
  249.     -2        Use two-pass color quantization (not yet supported).
  250.  
  251.     -d        Enable debug printout.  More -d's give more printout.
  252.  
  253. Color quantization currently uses a rather shoddy algorithm (although it's not
  254. so horrible when dithered).  Because of this, the GIF output mode is not
  255. recommended in the current release, except for gray-scale output.  You can get
  256. better results by applying ppmquant to the unquantized (PPM) output of djpeg,
  257. then converting to GIF with ppmtogif.  We expect to provide a considerably
  258. better quantization algorithm in a future release.
  259.  
  260. Note that djpeg *can* read noninterleaved JPEG files even though cjpeg can't
  261. yet generate them.  For most applications this is a nonissue, since hardly
  262. anybody seems to be using noninterleaved format.
  263.  
  264. On a non-virtual-memory machine, you may run out of memory if you use -I or -o
  265. in cjpeg, or -q ... -2 in djpeg, or try to read an interlaced GIF file.  This
  266. will be addressed eventually by replacing jvirtmem.c with something that uses
  267. temporary files for large images (see TO DO).
  268.  
  269.  
  270. REFERENCES
  271. ==========
  272.  
  273. The best and most readily available introduction to the JPEG compression
  274. algorithm is Wallace's article in the April '91 CACM:
  275.     Wallace, Gregory K.  "The JPEG Still Picture Compression Standard",
  276.     Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
  277. (Adjacent articles in that issue discuss MPEG motion picture compression,
  278. applications of JPEG, and related topics.)  We highly recommend reading that
  279. article before looking at any of the JPEG software.
  280.  
  281. For more detail about the JPEG standard you pretty much have to go to the
  282. draft standard, which is not nearly as intelligible as Wallace's article.
  283. The current version is ISO/IEC Committee Draft CD 10918-1 dated 1991-03-15.
  284. The standard is not presently available electronically; you must order a paper
  285. copy through ISO.
  286.  
  287. The JPEG standard does not specify all details of an interchangeable file
  288. format.  For the omitted details we follow the "JFIF" conventions, revision
  289. 1.01.  A copy of the JFIF spec is available from:
  290.     Literature Department
  291.     C-Cube Microsystems, Inc.
  292.     399A West Trimble Road
  293.     San Jose, CA  95131
  294.     (408) 944-6300
  295. Requests can also be e-mailed to info@c3.pla.ca.us (this address good after
  296. 10/10/91).  The same source can supply copies of the draft JPEG-in-TIFF specs.
  297.  
  298. If you want to understand this implementation, start by reading the
  299. "architecture" documentation file.  Please read "codingrules" if you want to
  300. contribute any code.
  301.  
  302.  
  303. SUPPORTING SOFTWARE
  304. ===================
  305.  
  306. You will probably want Jef Poskanzer's PBMPLUS image software; this provides
  307. many useful operations on PPM-format image files.  In particular, it can
  308. convert PPM images to and from a wide range of other formats.  You can FTP
  309. this free software from export.lcs.mit.edu (contrib/pbmplus*.tar.Z) or
  310. ftp.ee.lbl.gov (pbmplus*.tar.Z).
  311.  
  312. If you are using X Windows you might want to use the xv or xloadimage viewers
  313. to save yourself the trouble of converting PPM to some other format.
  314. Both of these can be found in the contrib directory at export.lcs.mit.edu.
  315.  
  316.  
  317. LEGAL ISSUES
  318. ============
  319.  
  320. The authors make NO WARRANTY or representation, either express or implied,
  321. with respect to this software, its quality, accuracy, merchantability, or
  322. fitness for a particular purpose.  This software is provided "AS IS", and you,
  323. its user, assume the entire risk as to its quality and accuracy.
  324.  
  325. This software is copyright (C) 1991, Thomas G. Lane.
  326. All Rights Reserved except as specified below.
  327.  
  328. Permission is hereby granted to use, copy, modify, and distribute this
  329. software (or portions thereof) for any purpose, without fee, subject to these
  330. conditions:
  331. (1) If any part of the source code for this software is distributed, then this
  332. README file must be included, with this copyright and no-warranty notice
  333. unaltered; and any additions, deletions, or changes to the original files
  334. must be clearly indicated in accompanying documentation.
  335. (2) If only executable code is distributed, then the accompanying
  336. documentation must state that "this software is based in part on the work of
  337. the Independent JPEG Group".
  338. (3) Permission for use of this software is granted only if the user accepts
  339. full responsibility for any undesirable consequences; the authors accept
  340. NO LIABILITY for damages of any kind.
  341.  
  342. Permission is NOT granted for the use of any author's name or author's company
  343. name in advertising or publicity relating to this software or products derived
  344. from it.  This software may be referred to only as "the Independent JPEG
  345. Group's software".
  346.  
  347. We specifically permit and encourage the use of this software as the basis of
  348. commercial products, provided that all warranty or liability claims are
  349. assumed by the product vendor.
  350.  
  351.  
  352. ansi2knr.c is included in this distribution by permission of L. Peter Deutsch,
  353. sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA.
  354. ansi2knr.c is NOT covered by the above copyright and conditions, but instead
  355. by the usual distribution terms of the Free Software Foundation; principally,
  356. that you must include source code if you redistribute it.  (See the file
  357. ansi2knr.c for full details.)  However, since ansi2knr.c is not needed as part
  358. of any product generated from the JPEG code, this does not limit you more than
  359. the foregoing paragraphs do.
  360.  
  361.  
  362. It appears that the arithmetic coding option of the JPEG spec is covered by
  363. patents held by IBM, and possibly also patents of AT&T and Mitsubishi.  Hence
  364. arithmetic coding cannot legally be used without obtaining one or more
  365. licenses.  For this reason, support for arithmetic coding has been removed
  366. from the free JPEG software.  (Since arithmetic coding provides only a
  367. marginal gain over the unpatented Huffman mode, it is unlikely that very many
  368. people will choose to use it.  If you do obtain such a license, contact
  369. jpeg-info@uunet.uu.net for a copy of our arithmetic coding modules.)  So far
  370. as we are aware, there are no patent restrictions on the remaining code.
  371.  
  372.  
  373. TO DO
  374. =====
  375.  
  376. Many of the modules need fleshing out to provide more complete
  377. implementations, or to provide faster paths for common cases.  The greatest
  378. needs are for (a) decent color quantization, and (b) a memory manager
  379. implementation that can work in limited memory by swapping "big" images to
  380. temporary files.  I (Tom Lane) am going to work on color quantization next.
  381. Volunteers to write a PC memory manager, or to work on any other modules, are
  382. welcome.
  383.  
  384. We'd appreciate it if people would compile and check out the code on as wide a
  385. variety of systems as possible, and report any portability problems
  386. encountered (with solutions, if possible).  Checks of file compatibility with
  387. other JPEG implementations would also be of interest.  Finally, we would
  388. appreciate code profiles showing where the most time is spent, especially on
  389. unusual systems.
  390.  
  391. Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net.
  392.